﻿<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	var sparepart = {
		gridId : "sparepartInDetailGrid",
		saveUrl : "sparepart/sparepartInDetail/save"
	};
</script>

<script type="text/javascript" src="js/widget/sparepart.js"></script>
<form:form id="sparepartInForm" commandName="model" cssClass="validate"
	action="sparepart/sparepartIn/save">
	<form:hidden path="id" />
<isperp:processProcesser processId="${model.processId }"></isperp:processProcesser>
	<table class=" form-table">
		<tr>
			<td class="td1">入库编号：</td>
			<td class="td2"><form:input path="code" disabled="true" /><span>
					(自动生成)</span></td>
			<td class="td1">入库日期：</td>
			<td class="td2"><form:input type="date" path="instockDate"
					cssClass="required" /></td>
		</tr>
		<tr>
			<td class="td1">供应商：</td>
			<td class="td2"><isperp:listSelector autocomplete="true"
					id="speSelector" afterSelectEmpty="" displayColumn="provider"
					name="providerId" autocompleteDisplay="item.data[o.displayColumn]"
					autocompleteUrl="configuration/ci/autocompleteProvlist"
					valueColumn="providerId" valueControlId=""
					displayValue="${model.providerId }"
					displayValueCssStyle="width:142px" displayValueCssClass="">
				</isperp:listSelector></td>
			<td class="td1">联系人：</td>
			<td class="td2"><form:input path="linkman" cssClass="required" />
			</td>
		</tr>
		<tr>

			<td class="td1">填表人：</td>
			<td class="td2"><label>${creatorName }</label></td>
			<td class="td1">联系电话：</td>
			<td class="td2"><form:input path="linktel" cssClass="required" />
			</td>
		</tr>
		<tr>
			<td class="td1">描述：</td>
			<td class="td2" colspan="3"><form:textarea path="memo"
					cssClass="required" /> </textarea>
			</td>
		</tr>

		<tr>
			<td class="td1">附件：</td>
			<td class="td2" colspan="3"><isperp:uploader
					sourceId="${model.id }" id="sptFiles"></isperp:uploader></td>
		</tr>
	</table>

	<isperp:grid
		url="sparepart/sparepartChangeDetail/listDetailsBySptSparepartId?sptSparepartId=${model.id }"
		gridId="sparepartInDetailGrid" showPager="false" showSearchbar="false"
		cusDialogSize="big" editurl="sparepart/sparepartInDetail/save"
		cusDeleteUrl="sparepart/sparepartChangeDetail/delete"
		cusFormatterActions="true">
		<jsp:attribute name="toolbar">
		<isperp:toolbar id="iconToolbar">
		   <div style="float:left;" class="header">
					<h3>需求清单</h3>
				</div>
			<isperp:button text="新增需求" icon="icon-plus" onclick="addDetail();"></isperp:button>
		</isperp:toolbar>
		</jsp:attribute>

		<jsp:body>
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<%-- <isperp:column name="conf_category_name" title="分类" width="150">
		</isperp:column> --%>
		<isperp:column name="name" title="名称" width="100">
		</isperp:column>
		<isperp:column name="specification" title="规格" width="100">
		</isperp:column>
		<isperp:column name="model" title="型号" width="100">
		</isperp:column>
		<isperp:column name="quantity" title="数量" width="120">   
		</isperp:column>
		<isperp:column name="price" title="单价" width="120">   
		</isperp:column>
		<isperp:column name="memo" title="备注" width="120">   
		</isperp:column>
	</jsp:body>
	</isperp:grid>
</form:form>
<script type="text/javascript">
	function addDetail() {
		isperp.openDialog({
			id : "addSinDetailDialog",
			windowSize : 'normal',
			contentUrl : 'sparepart/sparepartInDetail/addDetailEdit?pcontrolid=sparepartInDetailGrid&id=${model.id }&typeKey=sparepartIn',
			title : "新增需求"
		});
	}
	function addCi() {
		isperp.openDialog({
			id : "addCiDialog",
			contentUrl : 'configuration/ci/edit?pcontrolid=sparepartInCiDetailGrid&ty=sparepartIn&sourceId=${model.id }',
			title : "新增"
		});
	}
	function check(name) {
		var relationProRows = $("#sparepartInDetailGrid").jqGrid("getRowData");
		if (name == "提交"  && relationProRows.length < 1) {
			if ($("#sparepartInForm").valid() == false) {
				return false;
			}
			isperp.alert("请点击【新增需求】,添加需备件入库需求");
			return false;
		} else {
			return true;
		}
	}
</script>

<isperp:sparepartSelector relationId="${model.id }"
	gridId="sparepartInDetailGrid" formId="sparepartInForm"
	id="sparepartSelector"
	detailSaveUrl="sparepart/sparepartInDetail/saveDetails"></isperp:sparepartSelector>

<div class="header">
	<h3>关联流程</h3>
</div>

<isperp:processRelation businessKey="${model.id }" readonly="false"
	processKey="sparepartInProcess" projectIdControl="projectId"
	showTotalControl="relationProcessCount"></isperp:processRelation>

<isperp:buttonList>
	<isperp:processButtons processKey="sparepartInProcess" 
		processId="${model.processId }" businessKey="${model.id }"
		beforeSubmit="function(name){return check(name);}"
		formId="sparepartInForm"></isperp:processButtons>
</isperp:buttonList>

